<extend name="Public/base" />
<block name="style">
    <style>
        td{
            padding: 5px 2px!important;
        }
    </style>
</block>
<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>成本计算</h2>
    </div>
    <div ng-controller="DingjiaCtrl" ng-cloak class="ng-cloak" ng-init="dingjiainit()" style="font-size: 2px;">
        <form action="{:U('addbaseprice')}" id="myform" method="post" class="form-horizontal" style="width: 100%;font-size: small">
            <div class="cf">
                <table class="data-table table-striped" style="width: 50%">
                    <tr>
                        <th>选择采购批次</th>
                        <td>
                            <select select2 class="form-control input-3x" name="batch" ng-change="preDingjiaBatchSelect(preDingjiaBatch)" ng-model="preDingjiaBatch">
                                <option ng-repeat="b in preDingjiaBatchList">{{b}}</option>
                            </select>
                        </td>
                        <td>
                            <span ng-click="calculate()" class="btn btn-primary">计算成本</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="data-table table-striped" ng-show="olditems.length>0||items.length>0">
                <table>
                    <thead>
                    <tr>
                        <th colspan="2">数据编号</th>
                        <th>商品编码</th>
                        <th>商品[规格]</th>
                        <th>基础成本</th>
                        <th>世果成本</th>
                        <th>计算方式</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="item in items track by $index">
                            <td>
                                <span class="glyphicon glyphicon-level-up text-primary" style="font-size: 18px;" title="快速存储" ng-click="basepricequicksave($index)"></span>
                            </td>
                            <td>
                               <input type="text" name="id[]"  ng-model="item.id" class="form-control input-2-x" readonly/>
                            </td>
                            <td>
                                <input type="text" name="BIN[]" ng-model="item.BIN" class="form-control input-2x">
                            </td>
                            <td>
                                <span>{{item.erp_pname}}[{{item.erp_spec}}]</span>
                                <input type="text" name="erp_pname[]" ng-model="item.erp_pname" class="form-control input-2x hide"/>
                                <input type="text" name="erp_spec[]" ng-model="item.erp_spec" class="form-control input-2x hide"/>
                                <input type="text" name="total_weight[]" ng-model="item.total_weight" class="form-control input-2x hide"/>
                                <input type="text" name="total_num[]" ng-model="item.total_num" class="form-control input-2x hide"/>
                            </td>
                            <td>
                                <input type="text" name="base_price[]" ng-model="item.base_price" class="form-control input-2x"/>
                            </td>
                            <td>
                                <input type="text" name="sg_base_price[]" ng-model="item.sg_base_price" class="form-control input-3x"/>
                            </td>
                            <td>
                                <select class="form-control input-3x" ng-change="changeCalculateTpe(($index),item.calculateTypeSelected)" ng-model="item.calculateTypeSelected">
                                    <option ng-repeat="calculateTypeObj in item.calculateTypeArr" value="{{calculateTypeObj.calculateType}}" ng-selected="calculateTypeObj.selected">{{calculateTypeObj.CN}}</option>
                                </select>
                               <input type="text" name="calculate_type[]" ng-model="item.calculateType" class="hide">
                            </td>
                            <td>
                                <span class="btn btn-primary" ng-click="remove($index)">-</span>
                            </td>
                        </tr>
                    </tbody>



                </table>
                <div class="col-md-12">
                    <button type="submit" class=" btn btn-primary" target-form="form-horizontal">保存</button>
                    <a  class="btn btn-success" id="fh" onclick="javascript:history.back(-1); return false;">返 回</a>
                </div>
            </div>
        </form>
        <div class="modal fade" id="exampleModal" tabindex="-1" style="margin:200px;width: 100%;height: 100%" role="dialog" aria-labelledby="exampleModalLabel">
            <div class="modal-dialog" role="document" style="">
            </div>
        </div>
    </div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
    <script type="text/javascript" src="__JS__/dingjia.js"></script>
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('Dingjia/prolist')}');
        $(".time").datetimepicker({
            format: 'Y-m-d'
        });
        $("text").css("font-size",2);
    </script>
</block>
